<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>std::error_code error_from_exception(std::exception_ptr &amp;&amp;ep = std::current_exception(), std::error_code not_matched = std::make_error_code(std::errc::resource_unavailable_try_again)) noexcept - Boost.Outcome documentation</title>
<link rel="stylesheet" href="../../css/boost.css" type="text/css">
<meta name="generator" content="Hugo 0.52 with Boostdoc theme">
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>

<link rel="icon" href="../../images/favicon.ico" type="image/ico"/>
<body><div class="spirit-nav">
<a accesskey="p" href="../../reference/functions/try_operation_return_as.html"><img src="../../images/prev.png" alt="Prev"></a>
    <a accesskey="u" href="../../reference/functions.html"><img src="../../images/up.png" alt="Up"></a>
    <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../reference/functions/strong_swap.html"><img src="../../images/next.png" alt="Next"></a></div><div id="content">
  <div class="titlepage"><div><div><h1 style="clear: both"><code>std::error_code error_from_exception(std::exception_ptr &amp;&amp;ep = std::current_exception(), std::error_code not_matched = std::make_error_code(std::errc::resource_unavailable_try_again)) noexcept</code></h1></div></div></div>
  <p>This function saves writing boilerplate by rethrowing <code>ep</code> within a <code>try</code>
block, with a long sequence of <code>catch()</code> handlers, one for every standard
C++ exception type which has a near or exact equivalent code in 
<a href="https://en.cppreference.com/w/cpp/error/errc" class="api-reference" target="_blank"><i class="fa fa-book" aria-hidden="true"></i> <code>std::errc</code></a>
.</p>

<p>If matched, <code>ep</code> is set to a default constructed 
<a href="https://en.cppreference.com/w/cpp/error/exception_ptr" class="api-reference" target="_blank"><i class="fa fa-book" aria-hidden="true"></i> <code>std::exception_ptr</code></a>
,
and a 
<a href="https://en.cppreference.com/w/cpp/error/error_code" class="api-reference" target="_blank"><i class="fa fa-book" aria-hidden="true"></i> <code>std::error_code</code></a>
 is constructed using the ADL discovered free
function <code>make_error_code()</code> upon the <code>std::errc</code> enumeration value matching the
thrown exception.</p>

<p>If not matched, <code>ep</code> is left intact, and the <code>not_matched</code> error code supplied
is returned instead.</p>

<p><em>Overridable</em>: Not overridable.</p>

<p><em>Requires</em>: C++ exceptions to be globally enabled.</p>

<p><em>Namespace</em>: <code>BOOST_OUTCOME_V2_NAMESPACE</code></p>

<p><em>Header</em>: <code>&lt;boost/outcome/utils.hpp&gt;</code></p>


        </div><p><small>Last revised: February 01, 2019 at 23:42:52 UTC</small></p>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../../reference/functions/try_operation_return_as.html"><img src="../../images/prev.png" alt="Prev"></a>
    <a accesskey="u" href="../../reference/functions.html"><img src="../../images/up.png" alt="Up"></a>
    <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../reference/functions/strong_swap.html"><img src="../../images/next.png" alt="Next"></a></div></body>
</html>
